import request from "@/utils/request";
import { encryptedData } from "@/utils/encrypt";
import { loginRSA, tokenName } from "@/config";

export function logout() {
  return request({
    url: "/logout",
    method: "post",
  });
}

export function register() {
  return request({
    url: "/register",
    method: "post",
  });
}

/**
 * 登录
 * @param {*} data
 * @returns
 */
export async function API_login(data) {
  return request({
    url: "/user/login",
    method: "post",
    data,
  });
}

/**
 * 获取个人信息
 * @param {*} accessToken
 * @returns
 */
export function API_getUserInfo(data) {
  return request({
    url: `/user/get?code=${data.code}`,
    method: "post",
    data,
  });
}

/**
 * 用户&员工列表
 * @param {*} data
 * @returns
 */
export function API_userList(params) {
  return request({
    url: "/user/list",
    method: "get",
    params,
  });
}

/**
 * 用户&员工新增
 * @returns
 */
export function API_userCreate(data) {
  return request({
    url: "/user/create",
    method: "post",
    data,
  });
}

/**
 * 用户&员工修改
 * @returns
 */
export function API_userEdit(data) {
  return request({
    url: `/user/edit/${data.code}`,
    method: "put",
    data,
  });
}

/**
 * 用户&员工删除
 * @returns
 */
export function API_userDelete(data) {
  return request({
    url: `/user/delete/${data.code}`,
    method: "delete",
  });
}

/**
 * 用户&员工记录
 * @returns
 */
export function API_userGet(params) {
  return request({
    url: "/user/get",
    method: "get",
    params,
  });
}

/**
 * 设置用户密码
 * @param {*} params
 * @returns
 */
export function API_userSetpassword(data) {
  return request({
    url: `/user/setpassword/${data.password}`,
    method: "PATCH",
    data,
  });
}
